#!/bin/bash

# postinst script for zones-brand-bhyve
#
# see: dh_installdeb(1)

#set -e

# summary of how this script can be called:
#        * <postinst> \`configure' <most-recently-configured-version>
#        * <old-postinst> \`abort-upgrade' <new version>
#        * <conflictor's-postinst> \`abort-remove' \`in-favour' <package>
#          <new-version>
#        * <postinst> \`abort-remove'
#        * <deconfigured's-postinst> \`abort-deconfigure' \`in-favour'
#          <failed-install-package> <version> \`removing'
#          <conflicting-package> <version>
# for details, see http://www.debian.org/doc/debian-policy/ or
# the debian-policy package

PATH=/usr/bin:/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin
export PATH

if [ "${BASEDIR:=/}" = "/" ]; then
    BASEDIR=""
else
    BASEDIR_OPT="-b $BASEDIR"
fi

case "$1" in
    configure)
        chown root:bin $BASEDIR/usr/lib/brand/bhyve
	chown root:bin $BASEDIR/usr/share/bhyve
	chown root:bin $BASEDIR/usr/share/bhyve/kbdlayout
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/am ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/am
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/am"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/am"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/be ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/be
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/be"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/be"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/be_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/be_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/be_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/be_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/bg_bds ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/bg_bds
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/bg_bds"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/bg_bds"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/bg_phonetic ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/bg_phonetic
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/bg_phonetic"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/bg_phonetic"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/br ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/br
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/br"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/br"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/br_noacc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/br_noacc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/br_noacc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/br_noacc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/centraleuropean ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/centraleuropean
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/centraleuropean"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/centraleuropean"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ch ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ch
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ch"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ch"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ch-fr ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ch-fr
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ch-fr"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ch-fr"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ch-fr_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ch-fr_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ch-fr_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ch-fr_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ch_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ch_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ch_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ch_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ch_macbook_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ch_macbook_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ch_macbook_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ch_macbook_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/cz ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/cz
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/cz"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/cz"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/de ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/de
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/de"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/de"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/de_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/de_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/de_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/de_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/de_noacc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/de_noacc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/de_noacc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/de_noacc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/default ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/default
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/default"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/default"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/dk ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/dk
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/dk"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/dk"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/dk_macbook ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/dk_macbook
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/dk_macbook"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/dk_macbook"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ee ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ee
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ee"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ee"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/es ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/es
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/es"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/es"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/es_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/es_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/es_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/es_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/es_dvorak ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/es_dvorak
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/es_dvorak"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/es_dvorak"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/fi ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/fi
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/fi"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/fi"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/fr ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/fr
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/fr"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/fr"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/fr_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/fr_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/fr_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/fr_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/fr_dvorak ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/fr_dvorak
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/fr_dvorak"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/fr_dvorak"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/fr_dvorak_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/fr_dvorak_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/fr_dvorak_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/fr_dvorak_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/fr_macbook ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/fr_macbook
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/fr_macbook"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/fr_macbook"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/gr ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/gr
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/gr"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/gr"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/gr_101_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/gr_101_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/gr_101_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/gr_101_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/gr_elot_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/gr_elot_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/gr_elot_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/gr_elot_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/hr ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/hr
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/hr"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/hr"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/hu_101 ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/hu_101
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/hu_101"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/hu_101"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/hu_102 ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/hu_102
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/hu_102"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/hu_102"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/is ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/is
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/is"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/is"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/is_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/is_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/is_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/is_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/it ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/it
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/it"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/it"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/jp ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/jp
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/jp"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/jp"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/jp_capsctrl ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/jp_capsctrl
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/jp_capsctrl"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/jp_capsctrl"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/kz_io ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/kz_io
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/kz_io"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/kz_io"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/kz_kst ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/kz_kst
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/kz_kst"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/kz_kst"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/latinamerican ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/latinamerican
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/latinamerican"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/latinamerican"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/latinamerican_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/latinamerican_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/latinamerican_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/latinamerican_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/lt ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/lt
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/lt"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/lt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/nl ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/nl
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/nl"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/nl"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/no ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/no
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/no"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/no"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/no_dvorak ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/no_dvorak
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/no_dvorak"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/no_dvorak"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/nordic_asus-eee ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/nordic_asus-eee
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/nordic_asus-eee"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/nordic_asus-eee"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/pl_dvorak ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/pl_dvorak
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/pl_dvorak"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/pl_dvorak"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/pt ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/pt
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/pt"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/pt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/pt_acc ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/pt_acc
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/pt_acc"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/pt_acc"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ru ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ru
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ru"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ru"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ru_shift ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ru_shift
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ru_shift"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ru_shift"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ru_win ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ru_win
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ru_win"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ru_win"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/se ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/se
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/se"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/se"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/si ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/si
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/si"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/si"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/tr ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/tr
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/tr"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/tr"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/tr_f ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/tr_f
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/tr_f"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/tr_f"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ua ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ua
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ua"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ua"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/ua_shift_alt ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/ua_shift_alt
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/ua_shift_alt"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/ua_shift_alt"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/uk ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/uk
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/uk"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/uk"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/uk_capsctrl ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/uk_capsctrl
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/uk_capsctrl"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/uk_capsctrl"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/uk_dvorak ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/uk_dvorak
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/uk_dvorak"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/uk_dvorak"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/uk_macbook ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/uk_macbook
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/uk_macbook"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/uk_macbook"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorak ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorak
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorak"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorak"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakl ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakl
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakl"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakl"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakp ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakp
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakp"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakp"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakr ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakr
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakr"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakr"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakx ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakx
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakx"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/us_dvorakx"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/us_emacs ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/us_emacs
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/us_emacs"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/us_emacs"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/share/bhyve/kbdlayout/us_unix ] && rm -f $BASEDIR/usr/share/bhyve/kbdlayout/us_unix
	else
	    chmod 0444 "$BASEDIR/usr/share/bhyve/kbdlayout/us_unix"
	    chown root:bin "$BASEDIR/usr/share/bhyve/kbdlayout/us_unix"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/lib/brand/bhyve/zhyve ] && rm -f $BASEDIR/usr/lib/brand/bhyve/zhyve
	else
	    chmod 0555 "$BASEDIR/usr/lib/brand/bhyve/zhyve"
	    chown root:bin "$BASEDIR/usr/lib/brand/bhyve/zhyve"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/lib/rsrvrctl ] && rm -f $BASEDIR/usr/lib/rsrvrctl
	else
	    chmod 0555 "$BASEDIR/usr/lib/rsrvrctl"
	    chown root:bin "$BASEDIR/usr/lib/rsrvrctl"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/sbin/bhyve ] && rm -f $BASEDIR/usr/sbin/bhyve
	else
	    chmod 0555 "$BASEDIR/usr/sbin/bhyve"
	    chown root:bin "$BASEDIR/usr/sbin/bhyve"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/sbin/bhyvectl ] && rm -f $BASEDIR/usr/sbin/bhyvectl
	else
	    chmod 0555 "$BASEDIR/usr/sbin/bhyvectl"
	    chown root:bin "$BASEDIR/usr/sbin/bhyvectl"
	fi
	if [ "$ZONEINST" = "1" ]; then
	    [ -f $BASEDIR/usr/lib/brand/bhyve/bhhwcompat ] && rm -f $BASEDIR/usr/lib/brand/bhyve/bhhwcompat
	else
	    chmod 0755 "$BASEDIR/usr/lib/brand/bhyve/bhhwcompat"
	    chown root:bin "$BASEDIR/usr/lib/brand/bhyve/bhhwcompat"
	fi
    ;;

    abort-upgrade|abort-remove|abort-deconfigure)
    ;;

    *)
        echo "postinst called with unknown argument '$1'" >&2
        exit 1
    ;;
esac



# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.

#DEBHELPER#

exit 0

